package com.tanhua.server.service;

import com.tanhua.domain.mongo.UserLocation;
import com.tanhua.dubbo.api.mongo.UserLocationApi;
import com.tanhua.server.interceptor.UserHolder;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class LocationServer {
    @Reference
    private UserLocationApi userLocationApi;
    public void rerportLocation(Map<String, Object> locationMap) {
        Double latitude = (Double) locationMap.get("latitude");
        Double longitude = (Double) locationMap.get("longitude");
        String addrStr = (String) locationMap.get("addrStr");
        UserLocation userLocation = new UserLocation();
        userLocation.setUserId(UserHolder.getUserId());
        userLocation.setAddress(addrStr);
        userLocationApi.save(longitude,latitude,userLocation);
    }
}
